﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media.Imaging;
using ThreeByte.ActiveDeck.Assets.Resources;
using System.IO;

namespace ThreeByte.ActiveDeck.Dashboard.Converters
{
    public class UserAccessToIconConverter : IValueConverter
    {
        private static readonly BitmapSource AnonymousIcon;
        private static readonly BitmapSource RegisteredIcon;
        private static readonly BitmapSource ApprovedIcon;

        static UserAccessToIconConverter() {

            BitmapImage anonymousImage = new BitmapImage();
            anonymousImage.SetSource(new MemoryStream(UserAccessIcons.Anonymous));
            AnonymousIcon = anonymousImage;

            BitmapImage registeredImage = new BitmapImage();
            registeredImage.SetSource(new MemoryStream(UserAccessIcons.Registered));
            RegisteredIcon = registeredImage;

            BitmapImage approvedImage = new BitmapImage();
            approvedImage.SetSource(new MemoryStream(UserAccessIcons.Approved));
            ApprovedIcon = approvedImage;
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
            switch(System.Convert.ToInt32(value)) {
                case 0:
                    return AnonymousIcon;
                case 1:
                    return RegisteredIcon;
                case 2:
                    return ApprovedIcon;
            }
            return null;
        }


        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            throw new NotImplementedException("Cannot convert back from UserAccessToStringConverter");
        }
    }
}
